<!DOCTYPE html>
<title>This tests that DocumentFragment implements the ParentNode interface</title>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
setup({single_test: true});

var documentFragment = new DocumentFragment();

assert_equals(documentFragment.children.length, 0);
assert_equals(documentFragment.childElementCount, 0);
assert_equals(documentFragment.firstElementChild, null);
assert_equals(documentFragment.lastElementChild, null);

documentFragment.appendChild(new Text('a'));
assert_equals(documentFragment.children.length, 0);
assert_equals(documentFragment.childElementCount, 0);
assert_equals(documentFragment.firstElementChild, null);
assert_equals(documentFragment.lastElementChild, null);

var b = documentFragment.appendChild(document.createElement('b'));
assert_equals(documentFragment.children.length, 1);
assert_equals(documentFragment.childElementCount, 1);
assert_equals(documentFragment.children[0], b);
assert_equals(documentFragment.firstElementChild, b);
assert_equals(documentFragment.lastElementChild, b);

documentFragment.appendChild(new Text('c'));
assert_equals(documentFragment.children.length, 1);
assert_equals(documentFragment.childElementCount, 1);
assert_equals(documentFragment.children[0], b);
assert_equals(documentFragment.firstElementChild, b);
assert_equals(documentFragment.lastElementChild, b);

var d = documentFragment.appendChild(document.createElement(d));
assert_equals(documentFragment.children.length, 2);
assert_equals(documentFragment.childElementCount, 2);
assert_equals(documentFragment.children[0], b);
assert_equals(documentFragment.children[1], d);
assert_equals(documentFragment.firstElementChild, b);
assert_equals(documentFragment.lastElementChild, d);

documentFragment.appendChild(new Text('e'));
assert_equals(documentFragment.children.length, 2);
assert_equals(documentFragment.childElementCount, 2);
assert_equals(documentFragment.children[0], b);
assert_equals(documentFragment.children[1], d);
assert_equals(documentFragment.firstElementChild, b);
assert_equals(documentFragment.lastElementChild, d);
done();
</script>
